package com.bootemp.service;

import com.bootemp.bean.Dept;
import com.bootemp.mapper.DeptMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DeptService implements DeptMapper {
    @Resource
    public DeptMapper dm;

    /**
     * @Transactional是一个类注解，也是一个方法注解
     * @param d
     * @return
     */
    @Override
    @Transactional
    public int insert(Dept d) {
       int r= dm.insert(d);
       //算术异常
//        System.out.println(1/0);
        return r;
    }

    @Override
    public List<Dept> all() {
        return dm.all();
    }

    @Override
    public int delete(int id) {
        return dm.delete(id);
    }

    @Override
    public Dept one(int id) {
        return dm.one(id);
    }

    @Override
    public int update(Dept d) {
        return dm.update(d);
    }
}
